﻿var App = function () {
    var handleLoginForm = function () {
        $("#loginForm").validate({
            errorElement: "em", //default input error message container
            //errorClass: 'help-inline', // default input error message class
            //focusInvalid: false, // do not focus the last invalid input
            rules:{
                Identity:
                    {
                        required: true,
                        CheckHtml:true
                    },
                Password:
                {
                    required: true,
                    CheckHtml: true
                },
                verifycode:
                    {
                        required: true
                    }
            },

            messages: {
                Identity: {
                    required: "请输入用户名."
                },
                Password: {
                    required: "请输入密码."
                },
                verifycode:
                    {
                        required: "请输入验证码."
                    }
            },
            //invalidHandler: function (event, validator) { //display error alert on form submit   
            //    $('.alert-error', $("#loginForm")).show();
            //},

            //highlight: function (element) { // hightlight error inputs
            //    $(element)
            //        .closest('.block clearfix').addClass('error'); // set error class to the control group
            //},

            //success: function (label) {
            //    label.closest('.block clearfix').removeClass('error');
            //    label.remove();
            //},

            errorPlacement: function (error, element) {
                error.appendTo(element.parent());
                //error.addClass('help-small no-left-padding').insertAfter(element.closest('.input-icon'));
            },

            //submitHandler: function (form) {
            //    window.location.href = "index.html";
            //}
        });
    }
    //var error2 = $('.alert-error', form2);
    //var success2 = $('.alert-success', form2);

    return {
        init: {

        },
        initLogin: function () {
            handleLoginForm(); // handles login form
        }
    };
}();